﻿package Common
{
	import flash.utils.getTimer;
	
	
	public class FrameLimiter
	{		
		public static function limitFrame():Boolean
		{			
			if (Math.abs.apply(null, [m_newTime - m_oldTime]) < m_limitFPS)
			{
				m_newTime = getTimer();
				return true;
			}
			m_oldTime = getTimer();
			return false;
		}
		
		public static function set limitFPS(value:uint):void
		{
			m_limitFPS = 1000 / value;
		}
		
		private static var m_limitFPS:uint	= 1000 / 30;
		private static var m_oldTime:uint 	= getTimer();
		private static var m_newTime:uint 	= m_oldTime;
	}
}